Skip to content

refactor(session): retire agent session presenter#1964

Merged
zerob13 merged 5 commits into
devfrom
task/retire-agent-session-presenter
Jul 14, 2026
Merged

refactor(session): retire agent session presenter#1964
zerob13 merged 5 commits into
devfrom
task/retire-agent-session-presenter

Conversation

@zerob13

@zerob13 zerob13 commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the pass-through AgentSessionPresenter and main-process IAgentSessionPresenter contract.
  • Wire the composition root, routes, agent tools, hooks, floating widget, and MCP consumers directly to Lifecycle, Turn, AgentAssignment, and Projection.
  • Keep SessionService, ChatService, Remote, and Cron on narrow ports.
  • Migrate integration coverage, enforce facade retirement in architecture guards, and refresh architecture documentation and baselines.

Why

The compatibility facade owned no behavior but exposed the four session capability groups as one aggregate dependency. Removing it makes the existing coordinator ownership explicit and prevents callers from coupling to a replacement session facade.

Impact

Route names, IPC contracts, preload APIs, renderer clients, persistence behavior, and runtime semantics remain unchanged. Main-process consumers now depend on the coordinator capability they use.

Validation

  • pnpm run format
  • pnpm run format:check
  • pnpm run i18n
  • pnpm run lint
  • pnpm run typecheck
  • pnpm run test:main — 4108 passed, 198 skipped
  • pnpm run test:renderer — 1257 passed
  • Focused session application, route, floating widget, MCP, and architecture guard tests

Summary by CodeRabbit

  • Documentation

    • Updated architecture docs and diagrams to reflect direct ownership by session coordinators and the retirement of the legacy session presenter façade.
    • Added/expanded retirement plans, specifications, tasks, and historical notes.
    • Refreshed architecture baselines, metrics, and generation metadata.
  • New Features

    • Session routing now uses dedicated lifecycle, projection, turn, and agent-assignment ports.
    • Floating session UI and conversation/tool context flows were switched to the new coordinator model.
  • Tests

    • Refactored routing, integration, and presenter tests to use coordinator-based APIs.
    • Updated architecture-guard checks and added new coordinator test fixtures.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e29c4512-53d0-40e2-842f-0156c6d9355b

📥 Commits

Reviewing files that changed from the base of the PR and between e6cff3c and 75dd1f6.

📒 Files selected for processing (4)
  • docs/architecture/baselines/agent-system-layered-runtime-baseline.json
  • scripts/architecture-guard.mjs
  • src/main/presenter/index.ts
  • test/main/presenter/sessionBoundaryComposition.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/architecture/baselines/agent-system-layered-runtime-baseline.json
  • src/main/presenter/index.ts
  • scripts/architecture-guard.mjs

📝 Walkthrough

Walkthrough

The PR retires AgentSessionPresenter and IAgentSessionPresenter, rewires session operations through four coordinators, updates integration and route tests, strengthens retirement guards, and regenerates architecture documentation and baselines.

Changes

Session presenter retirement

Layer / File(s) Summary
Architecture contracts and ownership
docs/architecture/..., src/shared/types/presenters/*
Architecture specifications and public presenter types now describe direct coordinator ownership and remove the retired presenter interface and export.
Runtime and route wiring
src/main/presenter/..., src/main/routes/index.ts
Presenter consumers and route handlers use lifecycle, projection, turn, and assignment ports instead of AgentSessionPresenter.
Coordinator test migration
test/main/presenter/sessionApplication/*, test/main/routes/dispatcher.test.ts
Fixtures construct coordinator stacks, and integration tests invoke coordinator APIs directly.
Guards and baselines
scripts/*, docs/architecture/baselines/*
Retired paths and symbols are enforced, coordinator ownership is tracked, and generated architecture metrics are refreshed.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: retiring the AgentSessionPresenter session layer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/retire-agent-session-presenter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zerob13 zerob13 marked this pull request as ready for review July 14, 2026 02:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/architecture-guard.mjs (1)

1560-1582: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Avoid parsing each main source file twice

sourceFileForAst(source, filePath) always calls ts.createSourceFile, so the AST is rebuilt once for the retired-facade scan and again for importRecords on every isMainSource file. Hoist the parsed sourceFile and reuse it in both branches to cut the extra work.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/architecture-guard.mjs` around lines 1560 - 1582, Avoid rebuilding
the AST in the file loop by creating one sourceFile with sourceFileForAst for
each file before the retired-facade and isMainSource checks. Reuse that parsed
sourceFile for both findIdentifierNames and the importRecords logic, while
preserving the existing branch behavior for non-main files.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/presenter/index.ts`:
- Around line 961-966: Initialize HooksNotificationsService only once, rather
than reassigning this.hooksNotifications in the projection update path. Ensure
its getSession and getMessage dependencies lazily read from
this.sessionProjectionCoordinator so newSessionHooksBridge continues using the
current projection callbacks.

---

Outside diff comments:
In `@scripts/architecture-guard.mjs`:
- Around line 1560-1582: Avoid rebuilding the AST in the file loop by creating
one sourceFile with sourceFileForAst for each file before the retired-facade and
isMainSource checks. Reuse that parsed sourceFile for both findIdentifierNames
and the importRecords logic, while preserving the existing branch behavior for
non-main files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cbca39fd-e2bd-4987-9f5b-6dfd8e74a34f

📥 Commits

Reviewing files that changed from the base of the PR and between 750f229 and e6cff3c.

📒 Files selected for processing (44)
  • docs/architecture/agent-memory-system/spec.md
  • docs/architecture/agent-system-layered-runtime/README.md
  • docs/architecture/agent-system-layered-runtime/modules/shared-data-and-io.md
  • docs/architecture/agent-system.md
  • docs/architecture/baselines/agent-system-layered-runtime-baseline.json
  • docs/architecture/baselines/archive-reference-report.md
  • docs/architecture/baselines/dependency-report.md
  • docs/architecture/baselines/main-kernel-boundary-baseline.md
  • docs/architecture/baselines/main-kernel-migration-scoreboard.json
  • docs/architecture/baselines/main-kernel-migration-scoreboard.md
  • docs/architecture/baselines/zero-inbound-candidates.md
  • docs/architecture/deepchat-vs-acp-agents/spec.md
  • docs/architecture/event-system.md
  • docs/architecture/history-read-hot-path/spec.md
  • docs/architecture/retire-agent-session-presenter/plan.md
  • docs/architecture/retire-agent-session-presenter/spec.md
  • docs/architecture/retire-agent-session-presenter/tasks.md
  • docs/architecture/session-application-coordinators/plan.md
  • docs/architecture/session-application-coordinators/spec.md
  • docs/architecture/session-application-coordinators/tasks.md
  • docs/architecture/session-boundary-cleanup/spec.md
  • docs/architecture/session-management.md
  • docs/architecture/tool-system.md
  • scripts/agent-cleanup-guard.mjs
  • scripts/architecture-guard.mjs
  • scripts/generate-architecture-baseline.mjs
  • src/main/presenter/agentSessionPresenter/index.ts
  • src/main/presenter/floatingButtonPresenter/index.ts
  • src/main/presenter/index.ts
  • src/main/presenter/mcpPresenter/inMemoryServers/conversationSearchServer.ts
  • src/main/presenter/mcpPresenter/toolManager.ts
  • src/main/routes/index.ts
  • src/shared/types/presenters/agent-session.presenter.d.ts
  • src/shared/types/presenters/core.presenter.d.ts
  • src/shared/types/presenters/index.d.ts
  • test/main/presenter/floatingButtonPresenter/index.test.ts
  • test/main/presenter/mcpPresenter/toolManager.test.ts
  • test/main/presenter/presenterCallErrorHandler.test.ts
  • test/main/presenter/sessionApplication/assignmentCoordinatorFixture.ts
  • test/main/presenter/sessionApplication/projectionCoordinatorFixture.ts
  • test/main/presenter/sessionApplication/runtimeIntegration.test.ts
  • test/main/presenter/sessionApplication/sessionApplication.integration.test.ts
  • test/main/routes/dispatcher.test.ts
  • test/main/scripts/architectureGuard.test.ts
💤 Files with no reviewable changes (5)
  • src/main/presenter/agentSessionPresenter/index.ts
  • src/shared/types/presenters/agent-session.presenter.d.ts
  • src/shared/types/presenters/index.d.ts
  • scripts/agent-cleanup-guard.mjs
  • src/shared/types/presenters/core.presenter.d.ts

Comment thread src/main/presenter/index.ts Outdated
@zerob13 zerob13 merged commit b59250d into dev Jul 14, 2026
4 checks passed
@zhangmo8 zhangmo8 deleted the task/retire-agent-session-presenter branch July 14, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant